package kr.co.webmill.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DbSqliteHelper extends SQLiteOpenHelper {
	public static String DATABASE_NAME = "comments.db";
	private static int DATABASE_VERSION = 1;	
	public static String TABLE_COMMENTS = "comments";
	public static String COLUMN_ID = "_id";
	public static String COLUMN_COMMENT = "comment";
	private static String DATABASE_CREATE = "CREATE TABLE " + TABLE_COMMENTS 
			+ "(" 
			+ COLUMN_ID + " integer primary key autoincrement,"
			+ COLUMN_COMMENT + " text DEFAULT NULL );";
	public DbSqliteHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		Log.w(this.getClass().getName(), " Upgrading database to " 
				+ newVersion + " from " + oldVersion 
				+ ", which will destroy all old data");
		db.execSQL("DROPT TABLE IF EXISTS " + TABLE_COMMENTS);
		onCreate(db);
		
	}

}
